<!DOCTYPE html>
<html lang="en">

<include file="CommonSidebar:common-head"/>
<link href="__ROOT__/Application/Admin/Public/css/jquery.datetimepicker.css" rel="stylesheet">
<body>
<link href="__ROOT__/Application/Admin/Public/css/cropper/cropper.min.css" rel="stylesheet">
<link href="__ROOT__/Application/Admin/Public/css/main.css" rel="stylesheet">
<js href="__ROOT__/Application/Admin/Public/ueditor/ueditor.config.js"/>
<js href="__ROOT__/Application/Admin/Public/ueditor/ueditor.all.min.js"/>
<js href="__ROOT__/Application/Admin/Public/js/jquery-2.0.2.js"/>

<body>

<div id="wrapper">

    <!-- Navigation -->
    <include file="CommonSidebar:common-navbar"/>

    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">添加横幅</h1>
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        添加横幅
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-lg-12">
                                <form action="{:U('Banner/Addhanld')}" id="Frm" role="form" method="post">
                                    <input type="hidden" value="{$data.banner_id}" name="banner_id">

                                    <div class="form-group">
                                        <label>上传图片</label>

                                        <div class="goods-img-list">
                                            <if condition="$data['banner_img']">
                                                <div>
                                                    <img style="height: 250px" class="add-goods-img avatar-view"
                                                         src="{$data['banner_img']}" alt="">
                                                    <input name="banner_img" type="hidden"
                                                           value="{$data['banner_img']}">
                                                </div>
                                                <else/>
                                                <div>
                                                    <img class="add-goods-img avatar-view"
                                                         src="__ROOT__/Application/Admin/Public/images/default.png"
                                                         alt="">
                                                    <input name="picpath[]" type="hidden">
                                                </div>
                                            </if>

                                        </div>
                                        <p class="help-block" style="display: none">上传图片</p>
                                    </div>
                                    <if condition="$data['banner_url_type']">
                                        <input type="hidden" name="banner_url_type" value="{$data['banner_url_type']}">
                                        <else/>
                                        <div class="form-group">
                                            <label>横幅类型</label>
                                            <select name="banner_url_type" class="form-control">
                                                <option value="1">主题书单</option>
                                                <option value="4">商城轮播</option>
                                            </select>
                                        </div>
                                    </if>
                                    <div class="form-group">
                                        <label>横幅标题</label>
                                        <input class="form-control " type="text" name="banner_title"
                                               value="{$data.banner_title}"
                                               maxlength="255">
                                    </div>
                                    <div class="form-group">
                                        <label>横幅副标题(选填)</label>
                                        <input class="form-control " type="text" name="banner_f_title"
                                               value="{$data.banner_f_title}"
                                               maxlength="255">
                                    </div>
                                    <div class="form-group">
                                        <label>跳转链接</label>
                                        <input class="form-control URL" type="text" name="banner_url"
                                               value="{$data.banner_url}"
                                               maxlength="255">
                                    </div>
                                    <div class="form-group">
                                        <label>排序（输入整数0~999，数字越大排序越靠前。）</label>
                                        <input class="form-control" type="text" id="sort" name="banner_number"
                                               value="{$data.banner_number}">
                                    </div>
                                    <div class="form-group">
                                        <button type="submit" class="btn btn-next btn-default submit">确定提交</button>
                                    </div>

                                </form>
                            </div>
                            <!-- /.col-lg-6 (nested) -->
                        </div>
                        <!-- /.row (nested) -->
                    </div>
                    <!-- /.panel-body -->
                </div>
                <!-- /.panel -->
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->
    </div>
    <!-- /#page-wrapper -->

</div>

<include file="CommonSidebar:common-script"/>
<!-- Custom Theme JavaScript -->
<script src="__ROOT__/Application/Admin/Public/dist/js/sb-admin-2.js"></script>
<script type="text/javascript" src="__ROOT__/Application/Admin/Public/js/uploadPreview.js"></script>
<script type="text/javascript" src="__ROOT__/Application/Admin/Public/js/jquery.form.min.js"></script>
<script type="text/javascript" src="__ROOT__/Application/Admin/Public/js/jquery.qrcode.min.js"></script>

<include file="Common:common-cropper"/>
<script src="__ROOT__/Application/Admin/Public/dist/js/sb-admin-2.js"></script>
<script type="text/javascript" src="__ROOT__/Application/Admin/Public/js/bootstrapValidator.js"></script>
<script src="__ROOT__/Application/Admin/Public/js/cropper/cropper.min.js"></script>
<script src="__ROOT__/Application/Admin/Public/js/figure.js"></script>

<script>
    $(function () {
        new CropAvatar({
            container: '#crop-avatar',
            workspaces: '__ROOT',
            formUrl: "{:U('Pics/Pics')}",
            submitDone: function (data) {
                console.log(data);
                var $avatarView = $('.avatar-view');
                if (data.state == 1) {
                    var imgUrl = data.picpath;
                    $avatarView.attr('src', "{:C('ROOT_PIC_URL')}" + imgUrl);
                    $avatarView.attr('height', "250px");
                    $avatarView.next().val("{:C('ROOT_PIC_URL')}" + imgUrl);
                } else {
                    alert('Failed to response');
                }
            },
            delete: function (e) {
                var _this = e.target;
                var flag = _this.className.indexOf('close-goods-img');
                var $avatarView = $('.avatar-view');
                if (flag >= 0) {
                    var $elem = $(_this);
                    if (confirm("确认移除？")) {
                        $avatarView.show();
                        $elem.parent(".goods-img-item").remove();
                        $avatarView.next("input[name='thumbpicpath']").val("");
                        $avatarView.next("input[name='picpath']").val("");
                        $('.add-goods-img').attr('src', options.workspaces + '/Public/Boss/images/default.png')
                    }
                }
            }

        });
    });

    function submitcheck() {
        var $picid = $("input[name='picid']");
        if ($picid.val() == "") {
            $picid.parents(".form-group").removeClass("has-success").addClass("has-error");
            $picid.parents(".form-group").find(".help-block").show();
            return false;
        }
    }
</script>
</body>
</html>